package com.feihong.activity.configration;

import lombok.Data;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.common.serialization.StringSerializer;

import java.util.Properties;
/**
 * Kafka生产者
 * @author Filter
 */
@Data
public class KafkaProducerConfiguration {

    private KafkaProducer producer;
    private String topic ;
    public KafkaProducerConfiguration(String topicName) {
        Properties props = new Properties();
        props.put("bootstrap.servers", "10.21.200.150:9092");
        props.put("acks", "all");
        props.put("retries", "1");
        props.put("batch.size", "1024");
        props.put("linger.ms","1");
        props.put("buffer.memory", "33554432");
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        this.producer = new KafkaProducer<String, String>(props);
        this.topic = topicName;
    }

}
